<?php

/**
 * Source form base class.
 *
 * @method Source getObject() Returns the current form's model object
 *
 * @package    Coverd
 * @subpackage form
 * @author     Cameron Ross
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseSourceForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),
      'name'            => new sfWidgetFormInputText(),
      'provider'        => new sfWidgetFormChoice(array('choices' => array('itunes' => 'itunes', 'play' => 'play', 'twitter' => 'twitter', 'facebook' => 'facebook', 'email' => 'email'))),
      'provider_config' => new sfWidgetFormTextarea(),
      'rating'          => new sfWidgetFormInputText(),
      'icon_url'        => new sfWidgetFormInputText(),
      'disabled'        => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'              => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'name'            => new sfValidatorString(array('max_length' => 128)),
      'provider'        => new sfValidatorChoice(array('choices' => array(0 => 'itunes', 1 => 'play', 2 => 'twitter', 3 => 'facebook', 4 => 'email'))),
      'provider_config' => new sfValidatorString(array('required' => false)),
      'rating'          => new sfValidatorNumber(array('required' => false)),
      'icon_url'        => new sfValidatorString(array('max_length' => 128, 'required' => false)),
      'disabled'        => new sfValidatorInteger(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('source[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Source';
  }

}
